﻿<Window x:Class="Client.Windows.StartingWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:converters="clr-namespace:Client.Converters"
        xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        Width="500" Height="720"
        Background="{StaticResource NewPageBackground}" 
        WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary  Source="pack://application:,,,/Client;component/Resources/Resources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <converters:TitleConverter x:Key="titleConverter"/>
        </ResourceDictionary>
    </Window.Resources>

    <Window.Title>
        <Binding Path="CurrentPageViewModel.Name" Converter="{StaticResource titleConverter}"/>
    </Window.Title>

    <Grid Margin="1,10,1,5">

        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <ContentControl Grid.Row="0" Grid.RowSpan="6" Content="{Binding CurrentPageViewModel}" />
        <Grid Grid.Row="6">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="1*" />
            </Grid.ColumnDefinitions>

            <Button VerticalAlignment="Stretch" Margin="2" Grid.ColumnSpan="3" Width="Auto" 
                    Command="{Binding CurrentPageViewModel.SubmitCommand}" 
                    CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}}"
                    Content="Izaberi">
                <i:Interaction.Triggers>
                    <i:EventTrigger EventName="Click">
                        <i:InvokeCommandAction Command="{Binding CurrentPageViewModel.CurrentPageViewModel.CloseWindowCommand}"
                                               CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Window}}}"/>
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Button>
        </Grid>
    </Grid>
</Window>
